/*
 *  HoneywellUDP.h
 *  SmartHome
 *
 *  Created by Tiger.Yin on 10-4-14.
 *  Copyright 2010 Beijing Oriental Caesar Co.,Ltd. All rights reserved.
 *
 */
#ifndef _HONEYWELL_UDP_HEADER
#define	_HONEYWELL_UDP_HEADER

#ifndef	TCHAR
#define	TCHAR char
#endif

#define	MAX_UDP_REQ_LEN	100
#define	MAX_UDP_REP_LEN	512
#define	MAX_TOKEN_LEN	128



#define	DEFAULT_UDP_DELAY	500		// 500ms
#define	DEFAULT_UDP_DELAY_NUM	30		// 20*500=10000ms=10s
#define	DEFAULT_VERIFY_DELAY	600	// 10 minutes

#ifndef	_IN_HONEYWELL_UDP

extern char reply[MAX_UDP_REP_LEN];
extern char token[MAX_TOKEN_LEN];
extern char gUserName[64];
extern char gPassword[64];

extern int init_UDP_sock(char *server_ip, unsigned port);
extern void close_UDP_sock();
extern int send_UDP_data(char *data, int len);
extern int recv_UDP_reply();
extern int send_UDP_data_with_reply(char *srcdata, int len);

extern int send_cmd_verify(char *username, TCHAR *password);
extern int send_cmd_light(int id, int action, int onoff, int dimmer);
extern int send_cmd_ac485_cfg(int id, int onoff, int mode, int fan, int dir, int temp);
extern int send_cmd_ac485_req(int id, int *onoff, int *mode, int *fan,
							  int *dir, int *temp_set, int *temp_cur);
extern int send_cmd_irac(int id, int irid);
extern int send_cmd_irdev(int, int);
extern int send_cmd_ufh_cfg(int id, int onoff, int temp_set);
extern int send_cmd_ufh_req(int id, int *onoff, int *temp_set, int *temp_cur);
extern int send_cmd_relay_cfg(int id, int onoff);
extern int send_cmd_relay_req(int id, int *onoff);
extern int send_cmd_curtain(int id, int action, int onoff);
extern int send_cmd_zone_cfg(int zoneid, int ztype, int action);
extern int send_cmd_zone_req(int zoneid, int ztype, int statuskey, int *nstatuskey, char *zoneinfo);
extern int send_cmd_scenario_cfg(int sid);
extern int send_cmd_scenario_req(int areaid, int *sid);
extern int send_cmd_trigger_cfg(int id, int onoff);
extern int send_cmd_trigger_req(int id, int *sid);

#endif

#endif

